package 算法;

import com.sun.xml.internal.fastinfoset.tools.XML_SAX_StAX_FI;

public class 最长上升子序列 {
    public static void main(String[] args) {
        int i = new 最长上升子序列().lengthOfLIS(new int[]{10,9,2,5,3,7,101,18});
        System.out.println(i);
    }
    public int lengthOfLIS(int[] nums) {
        int[] maxLen = new int[nums.length];

        for (int i = 0; i < nums.length; i++) {
            maxLen[i] = 1;
            for (int j = i; j >= 0; j--) {
                if (nums[i] > nums[j]) {
                    maxLen[i] = Math.max(maxLen[j] + 1, maxLen[i]);
                }
            }
        }
        int res = 0;
        for (int i : maxLen) {
            res = res > i ? res:i;
        }
        return res;
    }
}
